<template>
  <div id="demo" style="width: 100%;height: 500px;"></div>
</template>

<script lang="ts" setup>
// 1. 导入
import * as echarts from 'echarts';
import { onMounted } from 'vue';

type EChartsOption = echarts.EChartsOption;
onMounted(() => {
  // 2. 设置echarts的容器
  var chartDom = document.getElementById('demo')!;
  // 3. 初始化
  var myChart = echarts.init(chartDom!);
  // 4. 选项
  var option: EChartsOption;
  option = {
    title: {
      text: 'ECharts 入门示例'
    },
    tooltip: {},
    xAxis: {
      data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
    },
    yAxis: {},
    series: [
      {
        name: '销量',
        type: 'bar',
        data: [5, 20, 36, 10, 10, 20]
      }
    ]
  };

  // 5. setOption 进行绘制
  option && myChart.setOption(option);

})
</script>
 
<style lang="less" scoped>
</style>